package com.saturday.provider.controller;

import com.saturday.provider.domain.Goods;
import com.saturday.provider.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :Lx
 * @Date :2021/1/22 0022 19:54
 * @Description：
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @Value("${server.port}")
    private String port;

    @GetMapping("/findOne/{id}")
    public Goods findOne(@PathVariable("id") int id){

        Goods goods = goodsService.findOne(id);
        goods.setTitle(goods.getTitle()+":"+port);//将端口号设置到上屏的title上，便于分辨
        return goods;
    }
}
